/**
 * 这里暴露一些通用的图表配置
 */
import type { EChartsOption } from 'echarts/types/dist/echarts.d.ts'
export type { EChartsOption }

/**
 * tooltip
 */
export const getBaseToolTip = (props?: any) => {
    return Object.assign(
        {},
        {
            trigger: 'axis',
            axisPointer: {
                type: 'shadow',
            },
        },
        props,
    )
}

/**
 * grid
 */
export const getBaseGrid = (props?: any) => {
    return Object.assign(
        {},
        {
            top: '36',
            left: '40',
            right: '40',
            bottom: '24',
            containLabel: true,
        },
        props,
    )
}

/**
 * xAxis
 */
export const getBaseXAxis = (props?: any) => {
    return Object.assign(
        {},
        {
            type: 'category',
            nameTextStyle: {
                color: '#606266',
                fontSize: '16',
                lineHeight: '16',
                align: 'right',
            },
            axisLabel: {
                color: '#909399',
                fontSize: '14',
                lineHeight: '14',
            },
            splitLine: {
                show: false,
            },
            axisLine: {
                show: false,
            },
            axisTick: {
                show: false,
            },
        },
        props,
    )
}

/**
 * yAxis
 */
// 只有一个y轴
export const getBaseSingleYAxis = (props?: any) => {
    return Object.assign(
        {},
        {
            type: 'value',
            nameTextStyle: {
                color: '#606266',
                fontSize: '16',
                lineHeight: '16',
                align: 'right',
            },
            min: 0,
            axisLabel: {
                color: '#909399',
                fontSize: '14',
                lineHeight: '14',
                fontFamily: 'FjallaOne-Regular',
            },
            splitLine: {
                show: false,
            },
            axisLine: {
                show: false,
            },
            axisTick: {
                show: false,
            },
            splitArea: {
                show: true,
                areaStyle: {
                    color: ['#F2F6FC', 'transparent'],
                },
            },
        },
        props,
    )
}
// 两个y轴
export const getBaseTwoYAxis = (props?: any[]) => {
    const yAxisOne = Object.assign(
        {},
        {
            type: 'value',
            nameTextStyle: {
                color: '#909399',
            },
            min: 0,
            axisLabel: {
                color: '#909399',
                fontSize: '14',
                lineHeight: '14',
                fontFamily: 'FjallaOne-Regular',
            },
            splitLine: {
                show: false,
            },
            axisLine: {
                show: false,
            },
            axisTick: {
                show: false,
            },
            splitArea: {
                show: true,
                areaStyle: {
                    color: ['#F2F6FC', 'transparent'],
                },
            },
        },
        props ? props[0] : {},
    )
    const yAxisTwo = Object.assign(
        {},
        {
            type: 'value',
            nameTextStyle: {
                color: '#909399',
            },
            min: 0,
            axisLabel: {
                color: '#909399',
                fontSize: '14',
                lineHeight: '14',
                fontFamily: 'FjallaOne-Regular',
            },
            splitLine: {
                show: false,
            },
            axisLine: {
                show: false,
            },
            axisTick: {
                show: false,
            },
            splitArea: {
                show: true,
                areaStyle: {
                    color: ['#F2F6FC', 'transparent'],
                },
            },
        },
        props ? props[1] : {},
    )
    return [yAxisOne, yAxisTwo]
}
